//
//  ViewController.m
//  demo6-代码创建视图
//
//  Created by Maggie on 15/8/8.
//  Copyright (c) 2015年 fmning. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    //初始化
    [self setUpView];
    
}

#pragma mark - 构建视图
- (void)setUpView{
    
    //UIButton->UIControl->UIView->UIResponder->NSObject
    //创建一个按钮
    UIButton *pushMeButton = [[UIButton alloc]init];
    
    //按钮在父视图中的位置和大小
    pushMeButton.frame = CGRectMake(20, 100, 100, 60);
    
    //设置标题
    [pushMeButton setTitle:@"Push Me" forState:UIControlStateNormal];
    [pushMeButton setTitle:@"Ok" forState:UIControlStateHighlighted];
    
    //设置字体颜色
    [pushMeButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    //设置背景颜色
    pushMeButton.backgroundColor = [UIColor yellowColor];
    
    //设置边框颜色
    pushMeButton.layer.borderColor = [[UIColor redColor] CGColor];
    pushMeButton.layer.borderWidth = 2;
    
    //添加事件响应
    [pushMeButton addTarget:self action:@selector(pushClicked:) forControlEvents:UIControlEventTouchUpInside];
    
    //添加到视图容器
    [self.view addSubview:pushMeButton];
    
    //UILable->UIView->UIResponder->NSObject
    UILabel *lbl = [[UILabel alloc]init];
    UIImageView *image;
}

#pragma mark - pushme按钮触发的方法
- (void)pushClicked:(UIButton *)sender{
    
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"你点击了我!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    
    [alert show];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
